<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="STYLESHEET" type="text/css" href="../pgadmin3.css">
<title>Guru Hints</title>
</head>

<body>

<h3>Editing Views, Stored Procedures or Functions</h3>
<p>
When editing the code for a view, stored procedure or function, instead of using the small
text box on the properties dialogue for the object, you might find it more convenient to 
use the scripting options in pgAdmin to edit the object in the query tool. This gives you the 
benefit of the Query Tool editor's features such as autocomplete, find and replace and larger
workspace.
</p>

<p>
To use the scripting options, in the pgAdmin browser window, right-click the object you wish
to edit, and select the <i>CREATE script</i> option. It may be on the <i>Scripts</i> submenu.
Alternatively, you can select the object and then choose the <i>CREATE script</i> option from
the <i>Scripts</i> submenu of the <i>Tools</i> menu. 
</p>

<p>
Edit the definition of the object as required, and
use the <i>Execute Query</i> button to apply your changes. Don't forget that modifying a view
or function name, or the signature of a function or procedure may result in a new
object being created alongside the original one. This useful side effect makes it convenient 
to create new, but similar objects. You may need to refresh the pgAdmin browser to display 
newly created objects.
</p>

<p>
You can use this technique to perform all sorts of operations on different objects, however 
PostgreSQL's <i>CREATE OR REPLACE</i> syntax makes it particularly useful for editing views,
stored procedures and functions.
</p>

</body>
</html>
